//
//  HECaseReportDetailsViewController.m
//  HealthElderly
//
//  Created by 吴欧 on 2021/6/18.
//  Copyright © 2021 honglutec. All rights reserved.
//

#import "HECaseReportDetailsViewController.h"
#import "HEGridImageView.h"

@interface HECaseReportDetailsViewController ()

@property (nonatomic, strong) UIScrollView *scrollView;
// 约束参照视图,也是容器视图
@property (nonatomic, strong) UIView *contentView;

@property (nonatomic, strong) UITextView *contentLb;
@property (nonatomic, strong) UILabel *titleLb;
@property (nonatomic, strong) HEGridImageView *gridView;

@end

@implementation HECaseReportDetailsViewController

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
   
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"病历记录详请";
    
    [self initUI];
}

- (void)initUI {
    
    // 1. 添加scrollView
    [self.view addSubview:self.scrollView];
    // 2. 添加参照视图
    [self.scrollView addSubview:self.contentView];
    
    
    // 标题
    _titleLb = [UILabel new];
    _titleLb.text = _model.case_name;
    _titleLb.font = DYBlodFont(19);
    _titleLb.numberOfLines = 0;
    [self.contentView addSubview:_titleLb];
    
    _gridView = [[HEGridImageView alloc] init];
    _gridView.imagesArray = [NSMutableArray arrayWithArray:_model.photos];
    [self.contentView addSubview: _gridView];
     
    
    // 上传时间
    UILabel *createTimeLb = [UILabel new];
    createTimeLb.text = [NSString stringWithFormat:@"上传时间：%@", [NSDate timestampToDate:_model.create_date formaterMode: NSDateFormaterModeDay]];
    createTimeLb.font = DYFont(17);
    createTimeLb.textColor = CNavDargGrayColor;
    [self.contentView addSubview: createTimeLb];
    
    [_titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).mas_offset(20);
        make.left.equalTo(self.contentView).mas_offset(15);
        make.right.equalTo(self.contentView).mas_offset(-15);
    }];
    
    [createTimeLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_titleLb.mas_bottom).mas_offset(20);
        make.left.equalTo(self.contentView).mas_offset(15);
        make.right.equalTo(self.contentView).mas_offset(-15);
    }];
 
    [_gridView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(createTimeLb.mas_bottom).mas_offset(20);
        make.left.equalTo(self.contentView);
        make.right.equalTo(self.contentView);
        make.bottom.equalTo(self.contentView);
    }];
    [_gridView shwoViewWithFixedSpacing:10 leadSpacing:15 tailSpacing:15 contentWidth:kScreenWidth];
}

- (void)viewDidLayoutSubviews {
    [super viewDidLayoutSubviews];
    // 布局子控件
    // 设置scrollView约束
    [self.scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.view).insets(UIEdgeInsetsMake(ZXNavBarHeight, 0, 0, 0));
    }];
    
    // 设置参照视图的约束
    [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.scrollView);
        make.width.equalTo(self.scrollView);
//        make.height.mas_greaterThanOrEqualTo(kScreenHeight-ZXNavBarHeight);
    }];
}

#pragma mark - getters
// scrollView
- (UIScrollView *)scrollView {
    if (_scrollView == nil) {
        _scrollView = [[UIScrollView alloc] init];
        _scrollView.backgroundColor = CViewBgColor;
        _scrollView.alwaysBounceVertical = YES;
    }
    return _scrollView;
}

// 约束参照视图
- (UIView *)contentView {
    if (_contentView == nil) {
        _contentView = [[UIView alloc] init];
        _contentView.backgroundColor = CViewBgColor;
    }
    return _contentView;
}


@end
